// 测试articleService
async function testArticleService() {
  // 由于ES模块的限制，我们需要使用动态导入
  try {
    // 模拟API响应
    const mockResponse = {
      articles: [
        { id: 1, title: '测试文章1', content: '内容1', viewCount: 100 },
        { id: 2, title: '测试文章2', content: '内容2', viewCount: 200 }
      ],
      total: 2
    };
    
    console.log('测试格式转换逻辑:');
    // 手动测试格式转换
    if (mockResponse.articles && Array.isArray(mockResponse.articles)) {
      const formattedResponse = {
        data: mockResponse.articles,
        total: mockResponse.total || mockResponse.articles.length,
        page: 1,
        limit: 10,
        totalPages: Math.ceil((mockResponse.total || mockResponse.articles.length) / 10)
      };
      console.log('转换后的响应:', formattedResponse);
      console.log('data字段是否存在:', formattedResponse.data !== undefined);
      console.log('data是否为数组:', Array.isArray(formattedResponse.data));
      console.log('文章数量:', formattedResponse.data.length);
    }
    
    console.log('\n测试完成!');
  } catch (error) {
    console.error('测试失败:', error);
  }
}

// 执行测试
testArticleService();